home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AIAT 1.0.1 / Headers / Accessor / IAAccessor.h next >
Encoding:
Text File  |  1997-09-11  |  3.8 KB  |  127 lines  |  [TEXT/CWIE]

  1. // IAAccessor.h
  2. //    Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5.  
  6. #ifndef IAAccessor_h
  7. #define IAAccessor_h
  8.  
  9. #pragma import on
  10.  
  11. #include "IAIndex.h"
  12.  
  13. //#pragma IA_BEGIN_IMPORTS
  14. #include <time.h>
  15. //#pragma IA_END_IMPORTS
  16.  
  17. #pragma IA_BEGIN_EXPORTS
  18.  
  19. //// IAHit: base class for search results
  20. class IAHit : public IAObject {
  21. public:
  22.                     IAHit(IAIndex* i, IADoc* d);
  23.     virtual            ~IAHit();                            // deletes doc
  24.     
  25.     void SetIndex (IAIndex* idx) {index = idx;}
  26.     void SetDocument (IADoc* docu) {doc = docu;}
  27.     
  28.     IAIndex* GetIndex() const {return index;}
  29.     IADoc*     GetDocument() const {return doc;}
  30.     
  31. private:
  32.                     IAHit(IAHit&);                            // don't define a copy constructor
  33.     IAIndex*        index;
  34.     IADoc*            doc;
  35. };
  36.  
  37. //// IAProgressReport: base class for progress reports
  38. class IAProgressReport : public IAObject {
  39. public:
  40.                     IAProgressReport();
  41.     IA_INLINE        ~IAProgressReport() IA_INLINE_DEF()        // no-op dtor def
  42.     void SetPercent (float value) {percent = value;}
  43.     void SetIndex (IAIndex* idx) {index = idx;}
  44.     void SetDocument (IADoc* docu) {doc = docu;}
  45.  
  46.     float    GetPercent () const {return percent;}    
  47.     IAIndex* GetIndex() const {return index;}
  48.     IADoc*     GetDocument() const {return doc;}
  49.     
  50. private:
  51.     void*            operator new(size_t size);                // stack allocate only
  52.     // A number between 0.0 and 100.0, inclusive.
  53.     float            percent;
  54.     // When index is non-NULL, it names index currently being processed.
  55.     IAIndex*        index;
  56.     // When doc is non-NULL, it names the document being processed.
  57.     IADoc*            doc;
  58.  
  59. };
  60.  
  61.  
  62. class IAAccessor : public IAObject {
  63. public:
  64.     // Note: the destructor does *not* delete indices.
  65.                         IAAccessor(IAIndex** indices, uint32 indexCount, uint32 type);
  66.     virtual                ~IAAccessor();
  67.  
  68.     // If the initialization was previously stored then it is restored,
  69.     // otherwise it is computed from scratch, which may be slow for large indices.
  70.     // By default uses a named block in the TOC of indices[0].storage.
  71.     void                Initialize(IAStorage* storage = NULL, IABlockID block = 0);
  72.  
  73.     // Computes and stores initializations so that, if the index has not changed,
  74.     // the accessor may be initialized much faster the next time.
  75.     // Accessor should not be initialized when this is called.
  76.     void                StoreInitialization(IAStorage* storage = NULL, IABlockID block = 0);
  77.     
  78.     // True iff valid initializations are available for this accessor.
  79.     // When this is true, Initialize() will be fast, otherwise, if the storage is writable,
  80.     // StoreInitialization() might be called instead.
  81.     bool                IsInitializationValid(IAStorage* storage = NULL, IABlockID block = 0);
  82.  
  83.     void    SetIndices (IAIndex** indexes) {indices = indexes;}
  84.     void    SetIndexCount (uint32 count) {indexCount = count;}
  85.     void    SetAccessorType (uint32 type) {accessorType = type;}
  86.     
  87.     IAIndex**    GetIndices () const {return indices;}
  88.     uint32        GetIndexCount () const {return indexCount;}
  89.     uint32        GetAccessorType () const {return accessorType;}
  90.     
  91. protected:
  92.     bool                isConstructed;
  93.     bool                isInitialized;
  94.  
  95.     // Called to actually compute initializations.
  96.     virtual void        Initializing() = 0;
  97.     
  98.     // Called to save and restore initializations.
  99.     virtual IABlockSize    InitsSize() = 0;
  100.     virtual void        StoringInits(IAOutputBlock* output) = 0;
  101.     virtual void        RestoringInits(IAInputBlock* input) = 0;
  102.  
  103.     // default constructor etc. so that this can be a virtual base class
  104.                         IAAccessor();
  105.     void                Constructing(IAIndex** indices, uint32 indexCount, uint32 type);
  106. private:
  107.     IABlockSize            InitValidationSize();
  108.     void                StoreInitValidation(IAOutputBlock* output);
  109.     bool                RestoreInitValidation(IAInputBlock* input);
  110.     
  111.     IAIndex**            indices;
  112.     uint32                indexCount;
  113.  
  114.     uint32                accessorType;
  115.  
  116.     
  117. };
  118.  
  119. IAExceptionCode            IAAccessorAlreadyInitialized = 'VAAI';
  120. IAExceptionCode            IAAccessorNotInitialized = 'VANI';
  121. IAExceptionCode            IAAccessorInitInvalid = 'VAIV';
  122.  
  123. #pragma IA_END_EXPORTS
  124.  
  125. #pragma import reset
  126.  
  127. #endif